]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Make getting the environment from gnome-session more robust
authorOwen W. Taylor <otaylor@fishsoup.net>
Sat, 24 Apr 2010 13:41:03 +0000 (09:41 -0400)
committerOwen W. Taylor <otaylor@fishsoup.net>
Sun, 9 May 2010 20:35:34 +0000 (16:35 -0400)
readlink() on /proc/<pid>/exe can have results like:

 /usr/bin/gnome-keyring-daemon.#prelink#.5DFZsF (deleted)
 /usr/bin/gnome-session (deleted)

To find gnome-session in a more robust way, read /proc/<pid>/cmdline
instead.

https://bugzilla.gnome.org/show_bug.cgi?id=616706

src/gnome-shell.in

index 27f7b0df018ebe7c52938516c89d7055a888464b..0cb6db71c073703484821d7aad5b2156227bfa9f 100644 (file)
@@ -37,10 +37,15 @@ def get_running_session_environs():
         if not stat.st_uid == myuid:
             continue
         try:
-            exe = os.readlink(piddir + '/exe')
-        except OSError, e:
+            f = open(piddir + "/cmdline")
+            command = f.read()
+            f.close()
+        except IOError, e:
             continue
-        if os.path.basename(exe) != 'gnome-session':
+        # /proc/cmdline is separated and terminated by NULs
+        command = command.split("\x00")[0]
+        command = os.path.basename(command)
+        if command != 'gnome-session':
             continue
         try:
             f = open(os.path.join(piddir, 'environ'))